﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace TripLOA.GUI.secure
{
    public partial class JoinedTrip : TripLOA.GUI.internationalization.LOABasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Security.TripLoaUser us = Security.TripLoaUserManager.Instance.getUser(User.Identity.Name);
                Groupware.TripManager.GetAllJoinedTrips(us);
                List<Groupware.Trip> joinedtrip = Groupware.TripManager.GetTripsWithReservationRequestByUserId(us.UserID); ;
                List<Groupware.Trip> accepttrip = Groupware.TripManager.GetAllJoinedTrips(us);
                JoinedGridVIew.DataSource = joinedtrip;
                JoinedGridVIew.DataBind();
                if(JoinedGridVIew.Rows.Count == 0)
                    msg_noTrip_1.Visible = true;
                AcceptGridVIew.DataSource = accepttrip;
                AcceptGridVIew.DataBind();
                if (AcceptGridVIew.Rows.Count == 0)
                    msg_noTrip_2.Visible = true;
            }
        }
       

       

        protected void JoinedGridVIew_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            JoinedGridVIew.PageIndex = e.NewPageIndex;
            JoinedGridVIew.DataBind();
        }

        protected void JoinedGridVIew_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            DataKey selectedTrip = JoinedGridVIew.DataKeys[e.NewSelectedIndex];
            Response.Redirect("..\\PassengerTripDetail.aspx?Trip=" + selectedTrip.Values[0].ToString(),false);
        }

        protected void AcceptGridVIew_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            AcceptGridVIew.PageIndex = e.NewPageIndex;
            AcceptGridVIew.DataBind();
        }

        protected void AcceptGridVIew_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            DataKey selectedTrip = AcceptGridVIew.DataKeys[e.NewSelectedIndex];
            Response.Redirect("..\\PassengerTripDetail.aspx?Trip=" + selectedTrip.Values[0].ToString(),false);
        }
    }
}
